package org.zkoss.zktc.unittest;

import org.junit.Assert;
import org.junit.Test;
import org.zkoss.zktc.core.junit.TestCaseBase;
import org.zkoss.zktc.core.widget.SelectWidget;
import org.zkoss.zktc.core.widget.Widget;
import org.zkoss.zktc.core.widget.WidgetDriver;
import org.zkoss.zktc.core.widget.Widgets;

public class SelectTestCase extends TestCaseBase{

	protected String getTestCaseUrl(){
		return getTestCaseUrl("/unit/select.zul");
	}
	
	@Test
	public void testSelect(){
		navigate(getTestCaseUrl());
		
		SelectWidget w = Widgets.toSelectWidget(findWidget("$listbox1"));
		w.select(0);
		Assert.assertEquals("A", findWidget("$lab").getValue());
		
		w.select(1);
		Assert.assertEquals("B", findWidget("$lab").getValue());

		w.select(2);
		Assert.assertEquals("C", findWidget("$lab").getValue());
		
		
	}
	
	@Test
	public void testSelectListbox(){
		WidgetDriver driver = getDriver();
		navigate(getTestCaseUrl());
		
		Widget w = (Widget)findWidget("$listbox2");
		w.findWidget("@listitem:eq(0)").click();
		Assert.assertEquals("D", findWidget("$lab").getValue());
		
		w.findWidget("@listitem:eq(1)").click();
		Assert.assertEquals("E", findWidget("$lab").getValue());

		w.findWidget("@listitem:eq(2)").click();
		Assert.assertEquals("F", findWidget("$lab").getValue());
		
		
	}
	
	
}
